package various;


import lejos.nxt.LCD;
import lejos.nxt.Motor;
import lejos.nxt.SensorPort;
import lejos.nxt.addon.ColorSensor;

public class ProvaColore {
	public static void main(String[] args) throws Exception {
		ColorSensor colore = new ColorSensor(SensorPort.S1);

		for (int i = 0; i < 50; i++) {
			int a = colore.getColorNumber();
			LCD.clear();
			LCD.drawInt(a, 0, 0);
			if (a == 0) {
				LCD.clear();
				LCD.drawString("nero", 0, 2);
				Motor.A.setSpeed(100);
				Motor.A.backward();
			} else if (a == 4) {
				LCD.clear();
				LCD.drawString("grigio", 0, 2);
				Motor.A.setSpeed(100);
				Motor.A.backward();
			} else if (a == 17) {
				LCD.clear();
				LCD.drawString("bianco", 0, 2);
				Motor.A.setSpeed(80);
				Motor.A.forward();
			} else {
				LCD.clear();
				LCD.drawString("no bianco, no nero, no grigio: " + a, 0, 2);
				Motor.A.stop();
			}
			Thread.sleep(500);
		}

	}

}
